home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 79 / maccd 79.iso / multimedial / GL Tron / Source / gltron / system_net_sdl.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-13  |  975 b   |  54 lines  |  [TEXT/CWIE]

  1. #include "system_net_sdl.h"
  2.  
  3. static TCPsocket socket; /* that's a pointer! */
  4.  
  5. #define SERVER_HOST "tulpe.ards.dataway.ch"
  6. #define SERVER_PORT 23460
  7.  
  8. void SystemNetExit() {
  9.   SDLNet_Quit();
  10. }
  11.  
  12. void SystemNetInit() {
  13.   SDLNet_Init();
  14. }
  15.  
  16. void SystemNet_Write32(int value, unsigned char *buf) {
  17.   SDLNet_Write32(value, buf);
  18. }
  19.  
  20. int SystemNet_Read32(unsigned char *buf) {
  21.   return SDLNet_Read32(buf);
  22. }
  23.  
  24. int SystemConnect() {
  25.   IPaddress address;
  26.  
  27.  
  28.   if(SDLNet_ResolveHost(&address, SERVER_HOST, SERVER_PORT) == 0) {
  29.     fprintf(stderr, "couldn't resolve host %s\n", SERVER_HOST);
  30.     return 1;
  31.   }
  32.  
  33.   if((socket = SDLNet_TCP_Open(&address)) == NULL) {
  34.     fprintf(stderr, "coulnd't establish socket connection\n");
  35.     return 1;
  36.   }
  37.   return 0;
  38. }
  39.  
  40. int SystemTCPrecv(char *buf, int length) {
  41.   return SDLNet_TCP_Recv(socket, buf, length);
  42. }
  43.  
  44. int SystemTCPsend(char *buf, int length) {
  45.   return SDLNet_TCP_Send(socket, buf, length);
  46. }
  47.  
  48. int SystemCheckSockets() {
  49.   return 0;
  50. }
  51.  
  52.  
  53.  
  54.